feat: add Slack and Discord Moss Q&A demo - #397
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an experimental community demo under moss-live-labs/community-demos/slack-discord-qa that answers workspace questions in Slack (Socket Mode app_mention) and Discord (!ask / bot mentions) using a shared Moss retrieval + OpenAI-compatible answering pipeline.
Changes:
- Introduces Slack and Discord adapters that extract questions and post threaded replies.
- Adds a shared
AnswerEnginewith bounded context construction and pluggable retriever/responder protocols. - Adds demo documentation, environment templates, packaging (
pyproject.toml), and credential-free unit tests.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| moss-live-labs/community-demos/slack-discord-qa/moss_slack_discord/adapters.py | Slack/Discord event adapters + question extraction logic |
| moss-live-labs/community-demos/slack-discord-qa/moss_slack_discord/qa_engine.py | Shared retrieval/response engine and bounded context builder |
| moss-live-labs/community-demos/slack-discord-qa/moss_slack_discord/app.py | App wiring: env loading, Moss index load, OpenAI responder, adapter startup |
| moss-live-labs/community-demos/slack-discord-qa/tests/test_adapters.py | Unit tests for Slack/Discord message extraction |
| moss-live-labs/community-demos/slack-discord-qa/tests/test_qa_engine.py | Unit tests for context building + answer engine behavior |
| moss-live-labs/community-demos/slack-discord-qa/README.md | Setup/configuration documentation for Slack + Discord |
| moss-live-labs/community-demos/slack-discord-qa/pyproject.toml | Demo package metadata, dependencies, script entrypoint, pytest config |
| moss-live-labs/community-demos/slack-discord-qa/moss_slack_discord/init.py | Package marker / module docstring |
| moss-live-labs/community-demos/slack-discord-qa/.env.example | Example environment variables for Moss/OpenAI/Slack/Discord |
| moss-live-labs/community-demos/slack-discord-qa/.gitignore | Ignores local env/venv/test caches |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| self.query_options_type = query_options_type | ||
|
|
||
| async def retrieve(self, question: str, top_k: int) -> list[RetrievedDocument]: | ||
| results = await self.client.query( |
There was a problem hiding this comment.
BLOCKING ```python
results = await self.client.query(
This queries the entire configured workspace index without carrying the caller, channel, server, or any authorization constraint from the chat event. If the index contains private channels or documents, any user who can reach the bot can ask for content they would not normally be allowed to read. Fix by passing request identity through `AnswerEngine.retrieve(...)` and restricting retrieval to authorized documents, for example with per-channel indexes or metadata/ACL filters on the Moss query.
| answer = await engine.answer(question) | ||
| except Exception: | ||
| answer = "I couldn't answer that right now. Please try again." | ||
| await message.reply(answer, mention_author=False) |
There was a problem hiding this comment.
CONSIDER ```python
await message.reply(answer, mention_author=False)
`mention_author=False` only suppresses the reply ping; it does not suppress mentions contained in the model-controlled `answer`. A user question or indexed document can cause the bot to emit `@everyone`, role, or user mentions if the bot has those permissions. Fix by passing `allowed_mentions=discord.AllowedMentions.none()` for generated replies, and apply the same outbound mention-suppression/sanitization policy to Slack responses.
Codex reviewThe demo is straightforward, but the current retrieval and response paths miss two safety boundaries that matter for a Slack/Discord workspace bot. |
Pull Request Checklist
Description
Summary
Adds a community demo that answers workspace questions in Slack and Discord using a shared Moss retrieval pipeline.
Implementation
!askmessages and direct bot mentions.Testing
uv run pytest— 8 passeduv run ruff check .— passeduv run ruff format --check .— passedCompatibility and risk
This is an additive experimental demo under
moss-live-labs/community-demos. Live Slack/Discord behavior requires platform credentials and a configured Moss index; those external integrations were not exercised locally.Fixes #384
Type of Change